Hệ thống quản lý thanh toán POS nhà hàng

1 Imports System.Data.OleDb
2 Public Class frmChangePassword
3     Declare Function Wow64DisableWow64FsRedirection Lib
"kernel32" (ByRef oldvalue As Long) As Boolean
4     Declare Function Wow64EnableWow64FsRedirection Lib
"kernel32" (ByRef oldvalue As Long) As Boolean
5
6     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
7         Try
8             Dim RowsAffected As Integer =
0
9             If Len(Trim(UserID.Text)) =
0 Then
10                 MessageBox.Show(
"Please enter user id", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
11                 UserID.Focus()
12                 Exit Sub
13             End If
14             If Len(Trim(OldPassword.Text)) =
0 Then
15                 MessageBox.Show(
"Please enter old password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
16                 OldPassword.Focus()
17                 Exit Sub
18             End If
19             If Len(Trim(NewPassword.Text)) =
0 Then
20                 MessageBox.Show(
"Please enter new password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
21                 NewPassword.Focus()
22                 Exit Sub
23             End If
24             If Len(Trim(ConfirmPassword.Text)) =
0 Then
25                 MessageBox.Show(
"Please confirm new password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
26                 ConfirmPassword.Focus()
27                 Exit Sub
28             End If
29             If NewPassword.TextLength <
5 Then
30                 MessageBox.Show(
"The New Password Should be of Atleast 5 Characters", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
31                 NewPassword.Text =
""
32                 ConfirmPassword.Text =
""
33                 NewPassword.Focus()
34                 Exit Sub
35             ElseIf NewPassword.Text <> ConfirmPassword.Text Then
36                 MessageBox.Show(
"Password do not match", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
37                 NewPassword.Text =
""
38                 OldPassword.Text =
""
39                 ConfirmPassword.Text =
""
40                 OldPassword.Focus()
41                 Exit Sub
42             ElseIf OldPassword.Text = NewPassword.Text Then
43                 MessageBox.Show(
"Password is same..Re-enter new password", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
44                 NewPassword.Text =
""
45                 ConfirmPassword.Text =
""
46                 NewPassword.Focus()
47                 Exit Sub
48             End If
49             con = New OleDbConnection(cs)
50             con.Open()
51             Dim co As String =
"update Registration set [password] =@d1 where userid=@d2 and [password] =@d3"
52             cmd = New OleDbCommand(co)
53             cmd.Parameters.AddWithValue(
"@d1", Encrypt(NewPassword.Text))
54             cmd.Parameters.AddWithValue(
"@d2", UserID.Text)
55             cmd.Parameters.AddWithValue(
"@d3", Encrypt(OldPassword.Text))
56             cmd.Connection = con
57             RowsAffected = cmd.ExecuteNonQuery()
58             If RowsAffected >
0 Then
59                 Dim st As String =
"Successfully changed the password"
60                 LogFunc(UserID.Text, st)
61                 frmCustomDialog.ShowDialog()
62                 Me.Hide()
63                 frmLogin.Show()
64                 frmLogin.UserID.Text =
""
65                 frmLogin.Password.Text =
""
66                 frmLogin.UserID.Focus()
67             Else
68
69                 MessageBox.Show(
"invalid user name or password", "input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
70                 UserID.Text =
""
71                 NewPassword.Text =
""
72                 OldPassword.Text =
""
73                 ConfirmPassword.Text =
""
74                 UserID.Focus()
75             End If
76             con.Close()
77         Catch ex As Exception
78             MessageBox.Show(ex.Message,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
79         End Try
80     End Sub
81     Sub OSKeyboard()
82         Dim old As Long
83         If Environment.Is64BitOperatingSystem Then
84             If Wow64DisableWow64FsRedirection(old) Then
85                 Process.Start(
"osk.exe")
86                 Wow64EnableWow64FsRedirection(old)
87             End If
88         Else
89             Process.Start(
"osk.exe")
90         End If
91     End Sub
92     Private Sub frmChangePassword1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
93         Me.Hide()
94         frmLogin.Show()
95         frmLogin.UserID.Text =
""
96         frmLogin.Password.Text =
""
97         frmLogin.UserID.Focus()
98     End Sub
99
100     Private Sub frmChangePassword_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
101         If e.KeyCode = Keys.Enter Then
102             Me.SelectNextControl(Me.ActiveControl, True, True, True, False)
'for Select Next Control
103         End If
104     End Sub
105
106     Private Sub frmChangePassword_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
107         Panel1.Location = New Point(Me.ClientSize.Width /
2 - Panel1.Size.Width / 2, Me.ClientSize.Height / 2 - Panel1.Size.Height / 2)
108         Panel1.Anchor = AnchorStyles.None
109     End Sub
110
111     Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
112         Me.Hide()
113         frmLogin.Show()
114         frmLogin.UserID.Text =
""
115         frmLogin.Password.Text =
""
116         frmLogin.UserID.Focus()
117     End Sub
118
119     Private Sub btnKeyboard_Click(sender As System.Object, e As System.EventArgs) Handles btnKeyboard.Click
120         OSKeyboard()
121     End Sub
122 End Class


Gõ tìm kiếm nhanh...